import itertools

import numpy as np
import pandas as pd

list1 = [1, 2, 3, 4, 5]

# 装饰器
'''
def watchTv(func):
    def show(*args, **kwargs):
        if 18 < args[0] < 31:
            print('可以看电视')
            return func(*args, **kwargs)
        print('不可以看电视')

    return show


@watchTv
def people(age):
    print('看电视')


people(25)
'''

# filter
'''
def is_double_or_none(x):
    if x is None:
        return False
    return x % 2 == 1
ls = filter(is_double_or_none, list1)

print(list(ls))
'''

# map
'''
ls = map(lambda x: x * x, list1)
print(list(ls))
'''

# 传递方法
'''
def area(a, b, f):
    return f(a) + f(b)
def f(a):
    return a + 100
print(area(1,2,f))
'''

# arr = np.full((10, 10), 999)
# print(arr)

# df = pd.DataFrame( [[1, 2, 3], [4, 5, 6]])
# print(df)

info1 = {'code': '91320100608982022N', 'tv_number': '宁交道罚字【2017】0500143号',
         'tv_content': '道路运输经营者使用卫星定位装置出现故障不能保持在线的运输...', 'tv_department': '南京市公路运输管理处', 'tv_date1': '2017-05-11',
         'tv_date2': '-', 'tv_detail': '责令立即改正、记道路运输车辆道路运输证件3分、记道路运输业户道路运输经营许可证件3分',
         'tv_punishment_basis': '《道路运输车辆动态监督管理办法》（交通运输部令2016年第55号修正）第37条'}
info2 = {'code': '91320100608982022N', 'tv_number': '宁栖环罚【2016】77号', 'tv_content': '-', 'tv_department': '南京市栖霞区环境保护局',
         'tv_date1': '2016-12-05', 'tv_date2': '2017-09-21', 'tv_detail': '大气污染', 'tv_punishment_basis': '-'}
info3 = {'code': '91320100608982022N', 'tv_number': '宁栖环罚〔2016〕40号', 'tv_content': '-', 'tv_department': '南京市栖霞区环境保护局',
         'tv_date1': '2016-08-04', 'tv_date2': '2017-09-21', 'tv_detail': '固废污染', 'tv_punishment_basis': '-'}
info4 = {'code': '91320100608982022N', 'tv_number': '宁栖环罚〔2016〕40号', 'tv_content': '-', 'tv_department': '南京市栖霞区环境保护局',
         'tv_date1': '2016-08-04', 'tv_date2': '2017-09-21', 'tv_detail': '固废污染', 'tv_punishment_basis': '-'}

list2 = [info1, info2, info3, info4]
# list2 = set([info1, info2, info3, info4])
print(list2)
# new_list = []
# for item in list2:
#     print(item['tv_number'])

# ids = [1,4,3,3,4,2,3,4,5,6,1]
#
# ids.sort()
print('xxxxxxxxxxxxxxxxx')
list2 = itertools.groupby(list2)
for i in list2:
    print(i)

# print(it)